package br.com.rookgraph.run;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

import br.com.rookgraph.GenerateGraph;
import br.com.rookgraph.Graph;

public class GenerateGraphsInFile {
	
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		System.out.println("Digite a quantidade de Grafos que deseja gerar:");
		int qntGrafos = in.nextInt();
		
		System.out.println("Digite o número de vertices para cada grafo: ");
		int numV = in.nextInt();
		
		System.out.println("Digite a Probabilidade de incidência de arestas (0-99): ");
		int probEdge = in.nextInt();
		
		String nameFile = "qnt"+qntGrafos+"numV"+numV+"probArestas"+probEdge+".txt";
		File file = new File("resources/graphs-generate/"+nameFile);
		
		try {
			
			FileWriter fw = new FileWriter(file);
			BufferedWriter out = new BufferedWriter(fw);
			
			GenerateGraph generateGraph = new GenerateGraph();
			out.write("@"+numV);
			out.newLine();
			
			for (int i = 1; i <= qntGrafos; i++) {
				Graph graph = generateGraph.generateWhit(numV, probEdge);
				out.write("#"+i);
				out.write(graph.toString());
				out.newLine();
				out.newLine();
				System.out.println("Grafo #"+i);
			}
						
			out.close();
			fw.close();
			
			file.createNewFile();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}

}
